package com.example.springdatajpaderivedquerymethod.repositories;

import com.example.springdatajpaderivedquerymethod.model.People;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;

public interface PeopleRepository extends CrudRepository<People,Integer> {

    @Transactional
    @Procedure(procedureName = "move_to_history")
    boolean movePersonToHistory(@Param("people_id") Integer peopleId);

    @Query(value = "call fetch_people_limit(:limitNum);",nativeQuery = true)
    List<People> getPeoplesByLimit(@Param("limitNum") final Integer limitNum);

    @Procedure(procedureName = "fetch_people_limit")
    List<People> fetchPeopleLimit(@Param("limitNum") final int limitNum);
}
